import { Controller } from 'egg';

export default class MessageController extends Controller {

  public async list() {
    const { ctx, service } = this;
    const validate = {
      userId: 'int',
    };
    ctx.validate(validate);
    ctx.body = await service.message.all(ctx.request.body.userId);
  }

  public async history() {
    const { ctx, service } = this;
    const validate = {
      userId: 'int',
      friendId: 'int',
    };
    ctx.validate(validate);
    const { userId, friendId } = ctx.request.body;
    ctx.body = await service.message.history(userId, friendId);
  }
}
